﻿@using MCP.BL
@model MCP.Data.Client.User
@{
    Layout = null;
}
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>MCP Log in</title>

    <link rel="Stylesheet" type="text/css" href="/Content/CSS.less" />
    <script src="/Scripts/jquery-1.8.3.js" type="text/javascript"></script>
    <script>
        $(function () {
            $('.helper').click(function () {
                var input = $('input', $(this).parent());
                input.val('').focus();
            });
        });
    </script>
</head>
    <body>
        
        @{
            var errorMessage = (ViewData["LoginErrorMessage"] ?? string.Empty).ToString();
            var resultType = ViewData["LoginErrorType"] as AuthenticationResultType?;
            var errorPlace = ViewData["NotificationPlace"] as ErrorNotificationPlace?;

            bool hasLoginError = errorMessage.Length > 0
                && resultType.HasValue && resultType != AuthenticationResultType.Authorized
                && errorPlace.HasValue;
        }

        <div id="distance"></div>
        <div>You can use demo account (login: "user"; pass: "user").</div>
        @using (Html.BeginForm("LogIn", "Account", FormMethod.Post, new { @class = "milk-border-left form-horizontal padding-large", @id = "login-form" }))
        {
            <legend>Please sign in</legend>
            <div class="grid">
                <div class="row ">
                    <div class="span2">
                        @Html.LabelFor(m => m.Username)
                    </div>
                    <div class="input-control text span2">
                        @Html.TextBoxFor(m => m.Username, new { placeholder = "Put your login here...", tabindex = "1", autofocus="autofocus"})
                        <a href="#" class="helper"></a>
                    </div>
                </div>
                <div id="login-error" class="error-place row">
                    @{
                        if (hasLoginError && errorPlace == ErrorNotificationPlace.Login)
                        {
                            <span class="error-message">@errorMessage</span>
                        }
                    }
                </div>
                <div class="row ">
                    <div class="span2">
                        @Html.LabelFor(m => m.Password)
                    </div>
                    <div class="input-control text span2">
                        @Html.PasswordFor(m => m.Password, new { placeholder = "Put your password here...", tabindex = "2" })
                        <a class="helper"></a>
                    </div>
                </div>
                <div id="password-error" class="error-place row">
                    @{
                        if (hasLoginError && errorPlace == ErrorNotificationPlace.Password)
                        {
                            <span class="error-message">@errorMessage</span>
                        }
                    }
                </div>
                <div class="row submit">
                    <input type="submit" value="Log In" class="btn" tabindex="3" />
                    @{
                        if (hasLoginError && errorPlace == ErrorNotificationPlace.General)
                        {
                            <span class="error-message">@errorMessage</span>
                        }
                    }
                </div>
                
            </div>
        }

       <footer class="login-footer">
            <a href="About" class="about-button icon-info">About</a>
        </footer>
    </body>
</html>
